﻿using EPiServer.Framework.Localization;
using EPiServer.Shell.ObjectEditing.EditorDescriptors;
using System;
namespace OpenWaves.EPiServer.GeoProperties
{
    public abstract class PropertyGeoObjectEditorDescriptor: EditorDescriptor
    {
        protected PropertyGeoObjectEditorDescriptor()
        {            
        }        

        protected abstract string PropertyUniqueName { get; }

        public override void ModifyMetadata(global::EPiServer.Shell.ObjectEditing.ExtendedMetadata metadata, System.Collections.Generic.IEnumerable<System.Attribute> attributes)
        {
            base.ModifyMetadata(metadata, attributes);
            metadata.EditorConfiguration.Add("googleMapsApiInfo", GoogleMapsApiInfo.Default);
            metadata.EditorConfiguration.Add("googleMapsApiKey", ServiceLocator.Resolve<IGeoPropertyConfiguration>().GoogleMapsApiKey);
        }

        protected void AddLocalizedValue(global::EPiServer.Shell.ObjectEditing.ExtendedMetadata metadata, string resourceKey, string fallback)
        {
            metadata.EditorConfiguration.Add(resourceKey, LocalizationService.Current.GetString(String.Format("/{0}/{1}", this.PropertyUniqueName, resourceKey), fallback));
        }
    }
}